﻿function CheckEmail(strMail) {
  if (strMail.length == 0) return false;
  var objReg = new RegExp("[A-Za-z0-9-_]+@[A-Za-z0-9-_]+[\.][A-Za-z0-9-_]");
  var IsRightFmt = objReg.test(strMail);
  var objRegErrChar = new RegExp("[^a-z0-9-._@]", "ig");
  var IsRightChar = (strMail.search(objRegErrChar) == -1);
  var IsRightLength = strMail.length <= 60;
  var IsRightPos = (strMail.indexOf("@", 0) != 0 && strMail.indexOf(".", 0) != 0 && strMail.lastIndexOf("@") + 1 != strMail.length && strMail.lastIndexOf(".") + 1 != strMail.length);
  var IsNoDupChar = (strMail.indexOf("@", 0) == strMail.lastIndexOf("@"));

  if (IsRightFmt && IsRightChar && IsRightLength && IsRightPos && IsNoDupChar) {
      return true;
  } else {
      return false;
    }
}

//获得Cookie的原始值
function GetCookie(name) {
  var cookies = document.cookie;
  var codeindex = cookies.indexOf(name);
  var startindex = codeindex + (name + "=").length;
  var vcode = cookies.substring(startindex, cookies.length);
  return vcode;
}

function refreshcode(target) {
  document.getElementById(target).src = "/tools/VerifyImagePage.aspx?time=" + Math.random();
}

/**  
*删除左右两端的空格  
*/
String.prototype.trim = function() {
  return this.replace(/(^\s*)|(\s*$)/g, '');
}
/**  
*删除左边的空格  
*/
String.prototype.ltrim = function() {
  return this.replace(/(^s*)/g, '');
}
/**  
*删除右边的空格  
*/
String.prototype.rtrim = function() {
  return this.replace(/(s*$)/g, '');
}